import pygame
import sys
from pygame.locals import *
from collections import deque
import random

from partingLine import PartingLine
from wall import Wall
from player import Player

if __name__ == "__main__":
    pygame.init()
    WIDTH, HEIGHT = (1000, 1000)
    SCREEN_SIZE = (WIDTH, HEIGHT)
    screen = pygame.display.set_mode(SCREEN_SIZE)
    pygame.display.set_caption("map")
    clock = pygame.time.Clock()
    unit_size = 20
    line = PartingLine(unit_size, screen, WIDTH, HEIGHT)
    wall = Wall(line)
    player = Player(line)
    while True:
        for event in pygame.event.get():
            if event.type == QUIT:
                pygame.quit()
                sys.exit()
            elif event.type == KEYDOWN:
                if event.key == K_ESCAPE:
                    print("########## saving date ############")
                    wall.save()
                    print("###########  end ##################")
                    pygame.quit()
                    sys.exit()
        background_color = (255,255,255)
        screen.fill(background_color)
        key = pygame.key.get_pressed()
        
        player.getKey(key)
        wall.getKey(key, player)
        ###########
        #start
        #end
        #path
        ###########


        line.draw()
        wall.draw()
        player.draw()
        pygame.display.update()
        pygame.display.flip()
        clock.tick(10)
